package org.custom.spring.boot.datasource.service.impl;

import org.custom.spring.boot.datasource.entity.RestTemplatePropertity;
import org.custom.spring.boot.datasource.service.RestTemplateService;
import org.custom.spring.boot.datasource.utils.RestTemplateUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.Map;

/**
 * RestTemplate相关服务接口实现
 *
 * @author 李坤
 * @date 2022/3/31 17:28
 */
@Service("restTemplateService")
public class RestTemplateServiceImpl implements RestTemplateService {

    @Resource
    private RestTemplate restTemplate;

    @Override
    public Map<String, Object> executeRequest(RestTemplatePropertity templatePropertity) {
        return restTemplate.exchange(RestTemplateUtil.generateRequestEntity(templatePropertity), Map.class).getBody();
    }

}
